import javaService from '../javaHttp'

function handel(data) {
  var params = new URLSearchParams()
  for (const key in data) {
    params.append(key, data[key])
  }
  return params
}
// 分页
export function role_getAllByPage(data) {
  return javaService({
    url: '/role/getAllByPage',
    method: 'GET',
    isLoading: true,
    params: data
  })
}
// 新增
export function role_save(data) {
  return javaService({
    url: '/role/save',
    method: 'POST',
    isLoading: true,
    data: handel(data)
  })
}
// 编辑
export function role_edit(data) {
  return javaService({
    url: '/role/edit',
    method: 'POST',
    isLoading: true,
    data: handel(data)
  })
}
// 是否默认
export function role_setDefault(data) {
  return javaService({
    url: '/role/setDefault',
    method: 'POST',
    isLoading: true,
    data: handel(data)
  })
}
// 修改菜单权限
export function role_editRolePerm(data) {
  return javaService({
    url: '/role/editRolePerm',
    method: 'POST',
    isLoading: true,
    data: handel(data)
  })
}
// 菜单权限 树形图
export function role_getAllList() {
  return javaService({
    url: '/permission/getAllList',
    method: 'GET',
    isLoading: true
  })
}
// 删除
export function department_del(data) {
  return javaService({
    url: '/role/delAllByIds/' + data,
    method: 'DELETE'
  })
}
// 数据权限 树形图
export function role_departmentTree() {
  return javaService({
    url: '/department/departmentTree',
    method: 'GET',
    isLoading: true
  })
}
// 数据权限 提交
export function role_editRoleDep(data) {
  return javaService({
    url: '/role/editRoleDep',
    method: 'POST',
    isLoading: true,
    data: handel(data)
  })
}
